package com.google.wave.poppy.mail;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** Singleton */;
public class MTA {
	private static MTA instance = new MTA();

	public static MTA get() { return instance; } 

//	public MimeMessage newMimeMessageToSubjBody(String recipient, String subject, String body) {
//		return SendMail.newMimeMessageToSubjBody("elliston@gmail.com", recipient, subject, body);
//	}
//	public boolean sendMessage(MimeMessage message) {
//		return SendMail.sendEmail(message);
//	}
	
	public Map<String,List<Message>> receiveMessages() {
		
		Map<String,List<Message>> result = new HashMap<String,List<Message>>();
		for (Message msg : FetchMail.fetchEmail()) {
			String waveID = msg.getWaveID();
			if (waveID == null) waveID = "waveID-unspecified";
			List messages = result.get(waveID);
			if (messages == null) {
				messages = new ArrayList();
				result.put(waveID, messages);
			}
			messages.add(msg);
		}
		return result;
		
	}
}
